*****!!!!!Set cd for your computer!!!!*******
cd ""


******Install necesarry user-written commands
foreach f in polychoric conjoint coefplot {
cap which `f'
if _rc {
net install `f'.pkg
}
}

/*
******Create Wide and Long Analytical Files*** 
*Note: can skip this step and also use _WIDE and _LONG files
run "Sust_supply_CODING.do"
*/

******Set font to Helvetica****
graph set window fontface "Arial"

******Use Long Data for Conjoint Analyses
use "Sust_supply_DATA_Long.dta", clear


******Figure One - Supply Chain Policy Preferences******
loc cj_cond size strict action
loc xlab 0.35(.05).65

encode country, gen(cntry_num)

preserve
use "Sust_supply_DATA_WIDE.dta", clear
//Panel A - Histogram 
qui sum supp_policy
loc supp_policy_mean=r(mean)
graph twoway ///
	(hist supp_policy, ///
		discrete percent ///
		col(sand)) ///
	(scatteri 0 `supp_policy_mean' 30 `supp_policy_mean', ///
		lc(maroon) lp(shortdash) recast(line)), ///
	ti("Support for New Supply Chain Regulations") ///
	xlab(	///
		1 `""Strongly" "Disagree""' ///
		7 `""Strongly" "Agree""' , ///
		nogrid) ///
	ylab(0(5)30, nogrid) ///
	yti("% of Responses") ///
	legend(off) ///
	note("{bf:A)}", pos(10) ring(12) size(small)) ///
	name(support_hist, replace) nodraw
restore

*MEM of Attributes
conjoint policy_support `cj_cond', est(mm) id(ResponseId)
mat overall = e(results)

*Save n and degress of freedom
loc obs1=e(N)
loc obs:di %7.0fc `obs1'
loc n1=e(N_clust)
loc n:di %6.0fc `n1'
loc df1=e(df_r)
loc df:di %6.0fc `df1'

*create panel B
coefplot ///
	(matrix(overall[,1]), ///
			keep( ///
				Very_large_companies ///
				Large_and_very_large_companies ///
				Medium_sized__large__and_very_la ///
				All_companies_with_25_employees_ ) ///
			mc(forest_green) ///
			ci((5 6)) ciopts(lc(forest_green))) /// 
	(matrix(overall[,1]), ///
			keep( ///
				Slightly_stricter ///
				Somewhat_stricter ///
				Much_stricter ) ///
			mc(edkblue) ///
			ci((5 6)) ciopts(lc(edkblue))) ///
	(matrix(overall[,1]), ///
			keep( ///
				Not_change_this ///
				Allow_for_some_government_action ///
				Allow_for_strong_government_acti) ///
			mc(maroon) ///
			ci((5 6)) ciopts(lc(maroon))), ///
	ti("Supply Chain Regulations Policy Instruments") ///
	xti("Pr(Selecting Proposal)", ///
	size(small)) level(95) msize(small) ///
	coefl( ///
		Very_large_companies = "Very large" ///
		Large_and_very_large_companies   = `""Large and" "very large""'  ///
		Medium_sized__large__and_very_la  = `""Medium, large" "and very large""' ///
		All_companies_with_25_employees_= "All" ///
		Slightly_stricter = "Slightly" ///
		Somewhat_stricter  = "Somewhat" ///
		Much_stricter   = "Much" ///
		Not_change_this  = "Not change" ///
		Allow_for_some_government_action   = "Some action" ///
		Allow_for_strong_government_acti  = "Strong action", ///
		labs(vsmall)  glc(white)) ///
	groups( ///
		Very_large_companies ///
		Large_and_very_large_companies ///
		Medium_sized__large__and_very_la ///
		All_companies_with_25_employees_ = ///
			`""{bf:Scope}" "{bf:Company Size}""' ///
		Slightly_stricter ///
		Somewhat_stricter ///
		Much_stricter = ///
			`""{bf:Transparency}" "{bf:Mandatory Reporting}""' ///
		Not_change_this ///
		Allow_for_some_government_action ///
		Allow_for_strong_government_acti = ///
			`""{bf:Enforcement}" "{bf:Government Action}""', ///
		ang(90) labs(small)) ///
	leg(off) /// 
	xlabel("`xlab'", format(%3.2f) nogrid) ///
	legend(off) ///
	xline(0.50, lp(shortdash) lc(gs5)) ///
	byopts(row(1)) ///
	note("{bf:B)}", pos(10) ring(12) size(small)) ///
	name(marg_means, replace) nodraw
	
gr combine ///
	support_hist ///
	marg_means, row(1) ///
	note("n=`n' respondents for Panel A. Error bars in Panel B represent 95% confidence intervals (df=`df') from `n' respondents * 10 choices for n=`obs' observations", ///
	s(tiny) pos(7)) ///
	name(fig_1, replace)

//Save Figure 1
gr export "figs/fig_1.pdf", as(pdf) ///
	name("fig_1") replace	

gr export "figs/fig_1.eps", as(eps) ///
	name("fig_1") replace
	
********Figure 2 - Results by country***************
foreach c in BE CA CH DE ES FR IT JA KO NL UK US {
conjoint policy_support `cj_cond' if country=="`c'", est(mm) id(ResponseId)
mat marg_means_`c' = e(results)
}

*Save n and degress of freedom
loc obs1=e(N)
loc obs:di %7.0fc `obs1'
loc n1=e(N_clust)
loc n:di %6.0fc `n1'
loc df1=e(df_r)
loc df:di %6.0fc `df1'

//Scope  sub fig
coefplot ///	
	(matrix(marg_means_US[,1]), ///
		m(O) mc(maroon) ///
		ci((5 6)) ciopts(lc(maroon))) ///
	(matrix(marg_means_DE[,1]), ///
		m(T) mc(forest_green) ///
		ci((5 6)) ciopts(lc(forest_green)))  ///
	(matrix(marg_means_JA[,1]), ///
		m(S) mc(edkblue) ///
		ci((5 6)) ciopts(lc(edkblue))) ///
	(matrix(marg_means_FR[,1]), ///
		m(D) mc(sand) ///
		ci((5 6)) ciopts(lc(sand))) ///
	(matrix(marg_means_UK[,1]), ///
		m(+) mc(orange) ///
		ci((5 6)) ciopts(lc(orange)))  ///
	(matrix(marg_means_NL[,1]), ///
		m(X) mc(gs6) ///
		ci((5 6)) ciopts(lc(gs6))) ///
	(matrix(marg_means_KO[,1]), ///
		m(Oh) mc(sienna) ///
		ci((5 6)) ciopts(lc(sienna))) ///
	(matrix(marg_means_IT[,1]), ///
		m(Th) mc(midgreen) ///
		ci((5 6)) ciopts(lc(midgreen)))  ///
	(matrix(marg_means_CA[,1]), ///
		m(Sh) mc(eltgreen) ///
		ci((5 6)) ciopts(lc(eltgreen))) ///
	(matrix(marg_means_ES[,1]), ///
		m(Dh) mc(sandb) ///
		ci((5 6)) ciopts(lc(sandb))) ///
	(matrix(marg_means_BE[,1]), ///
		m(smplus) mc(olive) ///
		ci((5 6)) ciopts(lc(olive)))  ///
	(matrix(marg_means_CH[,1]), ///
		m(smx) mc(gs12)	///
		ci((5 6)) ciopts(lc(gs12))), ///
	title("{bf:Scope}", bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	xti("Pr(Selecting Proposal)", ///
	size(small)) level(95) ///
	keep(Very_large_companies ///
		Large_and_very_large_companies ///
		Medium_sized__large__and_very_la ///
		All_companies_with_25_employees_ ) ///
	coefl( ///
		Very_large_companies ///
			= "Very large" ///
		Large_and_very_large_companies ///
			= `""Large and" "very large""'  ///
		Medium_sized__large__and_very_la ///
			= `""Medium, large" "and very large""' ///
		All_companies_with_25_employees_ ///
			= "All") ///
	legend(order( ///
		2 "USA" 4 "Germany" 6 "Japan" ///
		8 "France" 10 "UK" 12 "Netherlands" ///
		14 "S. Korea" 16 "Italy" 18 "Canada" ///
		20 "Spain" 22 "Belgium" 24 "Switzerland" ///
		) row(2) pos(6) size(vsmall)) ///
	xline(0.50, lp(shortdash) lc(gs5)) ///
	xlabel("`xlab'", format(%3.2f) angle(45)) ///
	ylabel(0.5 " " 1 `""Very" "Large""' 2 `""Large and" "very large""' ///
		3 `""Medium, large," "very large""' ///
		4 `""All" "Companies""' ///
		4.5 " ", labs(small) angle(90)) ///
	byopts(row(1)) name(company_cntry, replace) nodraw

//Transparency sub fig
coefplot ///	
	(matrix(marg_means_US[,1]), ///
		m(O) mc(maroon) ///
		ci((5 6)) ciopts(lc(maroon))) ///
	(matrix(marg_means_DE[,1]), ///
		m(T) mc(forest_green) ///
		ci((5 6)) ciopts(lc(forest_green)))  ///
	(matrix(marg_means_JA[,1]), ///
		m(S) mc(edkblue) ///
		ci((5 6)) ciopts(lc(edkblue))) ///
	(matrix(marg_means_FR[,1]), ///
		m(D) mc(sand) ///
		ci((5 6)) ciopts(lc(sand))) ///
	(matrix(marg_means_UK[,1]), ///
		m(+) mc(orange) ///
		ci((5 6)) ciopts(lc(orange)))  ///
	(matrix(marg_means_NL[,1]), ///
		m(X) mc(gs6) ///
		ci((5 6)) ciopts(lc(gs6))) ///
	(matrix(marg_means_KO[,1]), ///
		m(Oh) mc(sienna) ///
		ci((5 6)) ciopts(lc(sienna))) ///
	(matrix(marg_means_IT[,1]), ///
		m(Th) mc(midgreen) ///
		ci((5 6)) ciopts(lc(midgreen)))  ///
	(matrix(marg_means_CA[,1]), ///
		m(Sh) mc(eltgreen) ///
		ci((5 6)) ciopts(lc(eltgreen))) ///
	(matrix(marg_means_ES[,1]), ///
		m(Dh) mc(sandb) ///
		ci((5 6)) ciopts(lc(sandb))) ///
	(matrix(marg_means_BE[,1]), ///
		m(smplus) mc(olive) ///
		ci((5 6)) ciopts(lc(olive)))  ///
	(matrix(marg_means_CH[,1]), ///
		m(smx) mc(gs12)	///
		ci((5 6)) ciopts(lc(gs12))), ///
	title("{bf:Transparency}", ///
		bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	xti("Pr(Selecting Proposal)", ///
		size(small)) level(95) ///
	keep(Slightly_stricter ///
		Somewhat_stricter ///
		Much_stricter) ///
	coefl( ///
		Slightly_stricter ///
			= "Slightly" ///
		Somewhat_stricter  ///
			= "Somewhat" ///
		Much_stricter   ///
			= "Much") ///
	legend(order( ///
		2 "USA" 4 "Germany" 6 "Japan" ///
		8 "France" 10 "UK" 12 "Netherlands" ///
		14 "S. Korea" 16 "Italy" 18 "Canada" ///
		20 "Spain" 22 "Belgium" 24 "Switzerland" ///
		) row(2) pos(6)) ///
	xline(0.50, lp(shortdash) lc(gs5)) ///
	xlabel("`xlab'", format(%3.2f) angle(45)) ///
	ylabel(0.5 " " 1 `""Slightly" "more""' 2 `""Somewhat" "more""' ///
		3 `""Much" "more""' 3.5 " ", labs(small) angle(90)) ///
	byopts(row(1)) name(strict_cntry, replace) nodraw	
	
//Enforcement sub fig
coefplot ///	
	(matrix(marg_means_US[,1]), ///
		m(O) mc(maroon) ///
		ci((5 6)) ciopts(lc(maroon))) ///
	(matrix(marg_means_DE[,1]), ///
		m(T) mc(forest_green) ///
		ci((5 6)) ciopts(lc(forest_green)))  ///
	(matrix(marg_means_JA[,1]), ///
		m(S) mc(edkblue) ///
		ci((5 6)) ciopts(lc(edkblue))) ///
	(matrix(marg_means_FR[,1]), ///
		m(D) mc(sand) ///
		ci((5 6)) ciopts(lc(sand))) ///
	(matrix(marg_means_UK[,1]), ///
		m(+) mc(orange) ///
		ci((5 6)) ciopts(lc(orange)))  ///
	(matrix(marg_means_NL[,1]), ///
		m(X) mc(gs6) ///
		ci((5 6)) ciopts(lc(gs6))) ///
	(matrix(marg_means_KO[,1]), ///
		m(Oh) mc(sienna) ///
		ci((5 6)) ciopts(lc(sienna))) ///
	(matrix(marg_means_IT[,1]), ///
		m(Th) mc(midgreen) ///
		ci((5 6)) ciopts(lc(midgreen)))  ///
	(matrix(marg_means_CA[,1]), ///
		m(Sh) mc(eltgreen) ///
		ci((5 6)) ciopts(lc(eltgreen))) ///
	(matrix(marg_means_ES[,1]), ///
		m(Dh) mc(sandb) ///
		ci((5 6)) ciopts(lc(sandb))) ///
	(matrix(marg_means_BE[,1]), ///
		m(smplus) mc(olive) ///
		ci((5 6)) ciopts(lc(olive)))  ///
	(matrix(marg_means_CH[,1]), ///
		m(smx) mc(gs12)	///
		ci((5 6)) ciopts(lc(gs12))), ///	
	title("{bf:Enforcement}", ///
		bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	xti("Pr(Selecting Proposal)", ///
		size(small)) level(95) ///
	keep( ///
		Not_change_this ///
		Allow_for_some_government_action ///
		Allow_for_strong_government_acti) ///
	coefl( ///
		Not_change_this ///
			= "Not change" ///
		Allow_for_some_government_action ///
			= "Some action" ///
		Allow_for_strong_government_acti ///
			= "Strong action") ///
	legend(order( ///
		2 "USA" 4 "Germany" 6 "Japan" ///
		8 "France" 10 "UK" 12 "Netherlands" ///
		14 "S. Korea" 16 "Italy" 18 "Canada" ///
		20 "Spain" 22 "Belgium" 24 "Switzerland" ///
		) row(2) pos(6)) ///
	xline(0.50, lp(shortdash) lc(gs5)) ///
	xlabel("`xlab'", format(%3.2f) angle(45)) ///
	ylabel(0.5 " " 1 `""No" "changes""' 2 `""Some" "action""' ///
		3 `""Strong" "action""' 3.5 " ", labs(small) angle(90)) ///
	byopts(row(1)) name(action_cntry, replace) nodraw
	
//Combine figures together
grc1leg ///
	company_cntry ///
	strict_cntry ///
	action_cntry, row(1) ///
	note("Error bars in represent 95% confidence intervals (df=`df') from `n' respondents * 10 choices for n=`obs' observations for each country", ///
	s(tiny) pos(7)) ///
	name("fig_2", replace)
	
//Save Figure 2
gr export "figs/fig_2.pdf", as(pdf) ///
	name("fig_2") replace	

gr export "figs/fig_2.eps", as(eps) ///
	name("fig_2") replace



************Figure 3 - Policy Packages**********
//estimate conjoint coefficients
reg policy_support ///
	ib1.action##ib1.strict##ib4.size, ///
	cluster(ResponseId)
	
eststo reg_int_all

*Save n and degress of freedom
loc obs1=e(N)
loc obs:di %7.0fc `obs1'
loc n1=e(N_clust)
loc n:di %6.0fc `n1'
loc df1=e(df_r)
loc df:di %6.0fc `df1'

est res reg_int_all
margins, at(action=(3(-1)1) strict=(3(-1)1) size=(1(1)4)) post
est sto mar_int_all

//Plot package figure
coefplot mar_int_all, ///
	mc(edkblue) ciopts(lc(edkblue)) ///
	xtitle("Pr(Selecting Proposal)", s(small)) ///
	xlab(0.3(0.1)0.7, format(%2.1f)) ///
	xline(0.5, lc(black)) ///
	coefl( ///
		1._at = "{&ge} 25,000 Employees" ///
		2._at = "{&ge} 2,500 Employees" ///
		3._at = "{&ge} 250 Employees" ///
		4._at = "{&ge} 25 Employees" ///
		5._at = "{&ge} 25,000 Employees" ///
		6._at = "{&ge} 2,500 Employees" ///
		7._at = "{&ge} 250 Employees" ///
		8._at = "{&ge} 25 Employees" ///
		9._at = "{&ge} 25,000 Employees" ///
		10._at = "{&ge} 2,500 Employees" ///
		11._at = "{&ge} 250 Employees" ///
		12._at = "{&ge} 25 Employees" ///
		13._at = "{&ge} 25,000 Employees" ///
		14._at = "{&ge} 2,500 Employees" ///
		15._at = "{&ge} 250 Employees" ///
		16._at = "{&ge} 25 Employees" ///
		17._at = "{&ge} 25,000 Employees" ///
		18._at = "{&ge} 2,500 Employees" ///
		19._at = "{&ge} 250 Employees" ///
		20._at = "{&ge} 25 Employees" ///
		21._at = "{&ge} 25,000 Employees" ///
		22._at = "{&ge} 2,500 Employees" ///
		23._at = "{&ge} 250 Employees" ///
		24._at = "{&ge} 25 Employees" ///
		25._at = "{&ge} 25,000 Employees" ///
		26._at = "{&ge} 2,500 Employees" ///
		27._at = "{&ge} 250 Employees" ///
		28._at = "{&ge} 25 Employees" ///
		29._at = "{&ge} 25,000 Employees" ///
		30._at = "{&ge} 2,500 Employees" ///
		31._at = "{&ge} 250 Employees" ///
		32._at = "{&ge} 25 Employees" ///
		33._at = "{&ge} 25,000 Employees" ///
		34._at = "{&ge} 2,500 Employees" ///
		35._at = "{&ge} 250 Employees" ///
		36._at = "{&ge} 25 Employees" ///
		) ///
	groups( ///
		1._at 2._at 3_.at 4._at = `""Much" "More""' ///
		5._at 6._at 7_.at 8._at = `""Somewhat" "More""' ///
		9._at 10._at 11._at 12._at = `""Slightly" "More""' ///
		13._at 14._at 15_.at 16._at = `""Much" "More""' ///
		17._at 18._at 19_.at 20._at = `""Somewhat" "More""' ///
		21._at 22._at 23._at 24._at = `""Slightly" "More""' ///
		25._at 26._at 27_.at 28._at = `""Much" "More""' ///
		29._at 30._at 31_.at 32._at = `""Somewhat" "More""' ///
		33._at 34._at 35._at 36._at = `""Slightly" "More""', ///
		angle(rvertical)) ///
	heading(1._at = `""{bf:Strong}" "{bf:Enforcement Action}""' ///
	13._at = `""{bf:Some}" "{bf:Enforcement Action}""' ///
	25._at = `""{bf:No Changes}" "{bf:to Enforcement Action}""') ///
	 yscale(alt axis(2)) ysize(10) xsize(6) ///
	 r2title("{bf:Transparency - Mandatory Reporting}", orientation(rvertical)) ///
	 text(25 -0.075 "{it:Stringency}", ///
			orientation(vertical) s(medsmall)) ///
	text(53 0.4 "Error bars in represent 95% confidence intervals (df=`df') from `n' respondents * 10 choices", ///
			orientation(horizontal) s(vsmall)) ///
	text(53.75 0.4 "for n=`obs' observations", ///
			orientation(horizontal) s(vsmall)) ///
	name(fig_3, replace) 
	addplot fig_3:pcarrowi 50 -0.05 0 -0.05, ///
		norescaling lc(gs4) mc(gs4) lp(shortdash)
	
//Save Figure 3
gr export "figs/fig_3.pdf", as(pdf) ///
	name("fig_3") replace	

gr export "figs/fig_3.eps", as(eps) ///
	name("fig_3") replace	

************Figure 4- Subgroup Analyses*******
loc ylab 0.30(.05).70

//Left Right
qui reg policy_support ///
	ib4.size##c.poli_ori ///
	ib1.strict##c.poli_ori ///
	ib1.action##c.poli_ori ///
	i.cj_treat i.cntry_num, cluster(ResponseId)
eststo int_lr

*Save n and degress of freedom
loc obs1=e(N)
loc obs:di %7.0fc `obs1'
loc n1=e(N_clust)
loc n:di %6.0fc `n1'
loc df1=e(df_r)
loc df:di %6.0fc `df1'

est rest int_lr
qui margins, at(poli_ori=(1(1)11) size=(1(1)4)) post
eststo int_mar_lr_size
est res int_mar_lr_size
marginsplot, ///
	title("Political Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	plot4opts(lc(olive) mc(olive) m(Sh)) ///
	ci4opts(lc(olive)) ///
	ytitle("", s(small)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(1 "Left" 2 " " 3 " " 4 " " 5 " " 6 " " ///
	7 " " 8 " " 9 " " 10 " " 11 "Right") ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(5 "Very large" 6 ">=Large" ///
	7 ">=Medium" 8 "All Companies") ///
	pos(6) size(small) row(2)) ///
	name(int_mar_lr_size, replace) nodraw

est rest int_lr
qui margins, at(poli_ori=(1(1)11) strict=(1(1)3)) post
eststo int_mar_lr_strict
est res int_mar_lr_strict
marginsplot, ///
	title("Political Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle(" ", s(vsmall)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(1 "Left" 2 " " 3 " " 4 " " 5 " " 6 " " ///
	7 " " 8 " " 9 " " 10 " " 11 "Right") ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(4 "Slightly More" 5 "Somewhat More" ///
	6 "Much More") ///
	pos(6) size(small) row(2)) ///
	name(int_mar_lr_strict, replace) nodraw

est res int_lr	
qui margins, at(poli_ori=(1(1)11) action=(1(1)3)) post
eststo int_mar_lr_action
est res int_mar_lr_action
marginsplot, ///
	title("Political Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle(" ", s(vsmall)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(1 "Left" 2 " " 3 " " 4 " " 5 " " 6 " " ///
	7 " " 8 " " 9 " " 10 " " 11 "Right") ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend(order(4 "No changes" 5 "Some action" ///
	6 "Strong action") ///
	pos(6) size(small) row(2)) ///
	name(int_mar_lr_action, replace) nodraw


//Enviro Attitudes
qui reg policy_support ///
	ib4.size##c.enviro_attitudes ///
	ib1.strict##c.enviro_attitudes ///
	ib1.action##c.enviro_attitudes ///
	i.cj_treat i.cntry_num, cluster(ResponseId)
eststo int_ev

est rest int_ev
qui margins, at(enviro_attitudes=(-2(1)2) size=(1(1)4)) post
eststo int_mar_ev_size
est res int_mar_ev_size
marginsplot, ///
	title("Environmental Attitudes", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	plot4opts(lc(olive) mc(olive) m(Sh)) ///
	ci4opts(lc(olive)) ///
	ytitle("", s(small)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(5 "Very large" 6 ">=Large" ///
	7 ">=Medium" 8 "All Companies") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_ev_size, replace) nodraw
	
est rest int_ev
qui margins, at(enviro_attitudes=(-2(1)2) strict=(1(1)3)) post
eststo int_mar_ev_strict
est res int_mar_ev_strict
marginsplot, ///
	title("Environmental Attitudes", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle(" ", s(vsmall)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(4 "Slightly More" 5 "Somewhat More" ///
	6 "Much More") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_ev_strict, replace) nodraw

est res int_ev	
qui margins, at(enviro_attitudes=(-2(1)2) action=(1(1)3)) post
eststo int_mar_ev_action
est res int_mar_ev_action
marginsplot, ///
	title("Environmental Attitudes", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle(" ", s(vsmall)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(-2 `""-2" "SD""' -1 `""-1" "SD""' ///
	0 "Mean" 1 `""+1" "SD""' 2 `""+2" "SD""') ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend(order(4 "No changes" 5 "Some action" ///
	6 "Strong action") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_ev_action, replace) nodraw

//Social Value Orientation
qui reg policy_support ///
	ib4.size##b2.SVO ///
	ib1.strict##b2.SVO ///
	ib1.action##b2.SVO ///
	i.cj_treat i.cntry_num, cluster(ResponseId)
eststo int_svo

est rest int_svo
qui margins, at(SVO=(1(1)4) size=(1(1)4)) post
eststo int_mar_svo_size
est res int_mar_svo_size
marginsplot, ///
	title("Social Value Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	plot4opts(lc(olive) mc(olive) m(Sh)) ///
	ci4opts(lc(olive)) ///
	ylab("`ylab'",format(%3.2f)) ///
	ytitle("", s(small)) ///
	xlabel(1 `""Compe-" "titive""' 2 `""Individ-" "ualistic""' ///
	3 `""Pro-" "social""' 4 `""Altru-" "istic""', labs(vsmall)) ////
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(5 "Very large" 6 ">=Large" ///
	7 ">=Medium" 8 "All Companies") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_svo_size, replace) nodraw
	
est rest int_svo
qui margins, at(SVO=(1(1)4) strict=(1(1)3)) post
eststo int_mar_svo_strict
est res int_mar_svo_strict
marginsplot, ///
	title("Social Value Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("", s(small)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(1 `""Compe-" "titive""' 2 `""Individ-" "ualistic""' ///
	3 `""Pro-" "social""' 4 `""Altru-" "istic""', labs(vsmall)) ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend( ///
	order(4 "Slightly More" 5 "Somewhat More" ///
	6 "Much More") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_svo_strict, replace)  nodraw

est rest int_svo
qui margins, at(SVO=(1(1)4)  action=(1(1)3)) post
eststo int_mar_svo_action
est res int_mar_svo_action
marginsplot, ///
	title("Social Value Orientation", ///
	bex box bc(gs14) lc(black) lp(solid) bm(small)) ///
	plot1opts(lc(edkblue) mc(edkblue) m(Dh)) ///
	ci1opts(lc(edkblue)) ///
	plot2opts(lc(maroon) mc(maroon) m(Oh)) ///
	ci2opts(lc(maroon)) ///
	plot3opts(lc(forest_green) mc(forest_green) m(Th)) ///
	ci3opts(lc(forest_green)) ///
	ytitle("", s(small)) ///
	ylab("`ylab'",format(%3.2f)) ///
	xlabel(1 `""Compe-" "titive""' 2 `""Individ-" "ualistic""' ///
	3 `""Pro-" "social""' 4 `""Altru-" "istic""', labs(vsmall)) ///
	xti("") ///
	yline(0.50, lp(shortdash) lc(gs5)) ///
	legend(order(4 "No changes" 5 "Some action" ///
	6 "Strong action") ///
	pos(6) size(small) row(1)) ///
	name(int_mar_svo_action, replace) nodraw

	
//Make combined interacton figures
grc1leg 	///
	int_mar_ev_size ///
	int_mar_lr_size ///
	int_mar_svo_size, ///
	ycomm row(1) ///
	ti("{bf:Scope - Company Size}") ///
	note("A)", pos(10) ring(12)) ///
	name(size_int, replace) 
gr close size_int
	
grc1leg 	///
	int_mar_ev_strict ///
	int_mar_lr_strict ///
	int_mar_svo_strict, ///
	ycomm row(1) ///
	ti("{bf:Transparency - Mandatory Reporting}") ///
	note("B)", pos(10) ring(12)) ///
	name(strict_int, replace) 
gr close strict_int

	
grc1leg 	///
	int_mar_ev_action ///
	int_mar_lr_action ///
	int_mar_svo_action, ///
	ycomm row(1) ///
	ti("{bf:Enforcement - Government Action}") ///
	note("C)", pos(10) ring(12)) ///
	name(action_int, replace) 
gr close action_int

gr combine ///
	size_int ///
	strict_int ///
	action_int, col(1) ///
	ysize(10) xsize(6) ///
	note("Error bars in represent 95% confidence intervals (df=`df') from `n' respondents * 10 choices for n=`obs' observations",  ///
	s(tiny) pos(7)) ///
	name(fig_4, replace)
	
//Save Figure 4
gr export "figs/fig_4.pdf", as(pdf) ///
	name("fig_4") replace	

gr export "figs/fig_4.eps", as(eps) ///
	name("fig_4") replace	

************Figure 5- By Treatments*******
foreach t of numlist 1/3 {
conjoint policy_support `cj_cond' if cj_treat==`t', est(mm) id(ResponseId)
mat marg_means_T`t' = e(results)
loc obs1_`t'=e(N)
loc obs_`t':di %7.0fc `obs1_`t''
loc n1=e(N_clust)
loc n_`t':di %6.0fc `n1'
loc df1=e(df_r)
loc df_`t':di %6.0fc `df1'
}
loc obs1=`obs1_1'+`obs1_2'+`obs1_3'
loc obs:di %7.0fc `obs1'

//Save n and degress of freedom


//Make Figure
coefplot ///
	(matrix(marg_means_T1[,1]), ///
		m(Oh) mc(maroon) ///
		ci((5 6)) ciopts(lc(maroon))) ///
	(matrix(marg_means_T2[,1]), ///
		m(Th) mc(forest_green) ///
		ci((5 6)) ciopts(lc(forest_green)))  ///
	(matrix(marg_means_T3[,1]), ///
		m(Sh) mc(edkblue) ///
		ci((5 6)) ciopts(lc(forest_green))), ///
	keep(*:) ///
	ti("Supply Chain Regulations Policy Instruments") ///
	xti("Pr(Selecting Proposal)", ///
	size(small)) level(95) msize(small) ///
	coefl( ///
		Very_large_companies = "Very large" ///
		Large_and_very_large_companies   = `""Large and" "very large""'  ///
		Medium_sized__large__and_very_la  = `""Medium, large" "and very large""' ///
		All_companies_with_25_employees_= "All" ///
		Slightly_stricter = "Slightly" ///
		Somewhat_stricter  = "Somewhat" ///
		Much_stricter   = "Much" ///
		Not_change_this  = "Not change" ///
		Allow_for_some_government_action   = "Some action" ///
		Allow_for_strong_government_acti  = "Strong action", ///
		labs(vsmall)  glc(white)) ///
	eqlabels( ///
		`""{bf:Scope}" "{bf:Company Size}""' ///
		`""{bf:Transparency}" "{bf:Mandatory Reporting}""' ///
		`""{bf:Enforcement}" "{bf:Government Action}""', ///
		ang(90) labs(vsmall))  ///
	legend(order(2 "Control" 4 "Con-Market" 6 "Pro-Market") ///
		row(1) pos(6)) ///
	note("Error bars in represent 95% confidence intervals of marginal means for n=`n_1' control,  n=`n_2' con-market and n=`n_3' pro-market treated respondents for a total of `obs' observations", ///
	s(tiny) pos(7)) ///
	xline(0.50, lp(shortdash) lc(gs5)) ///
	xlabel("`xlab'", format(%3.2f)) ///
	byopts(row(1)) name(fig_5, replace)
		
//Save Figure 5
gr export "figs/fig_5.pdf", as(pdf) ///
	name("fig_5") replace	

gr export "figs/fig_5.eps", as(eps) ///
	name("fig_5") replace	


*********Figure 6*************
	
//Upload data
use "Sust_supply_DATA_WIDE.dta", clear

//Estimate coefficient and calculate marginal means
sum probe_hurtconsumer
loc hurt_mean=r(mean)

regress probe_hurtconsumer b1.probe_exp
margins, at(probe_exp=(1 2 3)) post
est sto marg_consumer
loc n1=e(N)
loc n:di %6.0fc `n1'
loc df1=e(df_r)
loc df:di %6.0fc `df1'


//Make plot using coefplot
coefplot (marg_consumer, ///
			keep(1._at) ///
			mc(forest_green) ciopts(lc(forest_green))) ///
			(marg_consumer, ///
			keep(2._at) ///
			mc(edkblue) ciopts(lc(edkblue))) ///
			(marg_consumer, ///
			keep(3._at) ///
			mc(maroon) ciopts(lc(maroon))),	///
	coefl( ///
		1._at = "Low" /// 
		2._at = "Medium" /// 
		3._at = "High" /// 
		) ///
	yti("{bf:Treatment: Policy Package Stringency}", ///
		angle(90) s(small)) ///
	ti(`""{bf:This new law would hurt consumers by making imported products more expensive}""', s(small)) ///
	xti("Marginal Means", s(small)) ///
	b1ti("Responses to 7 item Likert scale - 1 'Strongly disagree' to 7 'Strongly agree'", s(small)) ///
	xline(`hurt_mean', lc(black)) ///
	xline(4, lc(gs12) lp(shortdash)) ///
	xlab( ///
	3.8(0.1)4.8, format(%2.1f)) ///
	ylab(,glc(black))  legend(off) ///
	note("Error bars represent 95% confidence intervals (df=`df') from n=`n' respondents", s(vsmall) pos(7)) ///
	name(fig_6, replace)

//Save figure 6
gr export "figs/fig_6.pdf", as(pdf) ///
	name("fig_6") replace	

gr export "figs/fig_6.eps", as(eps) ///
	name("fig_6") replace
